package com.scwatch.core.domain;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * Created by rh006 on 2017/7/25.
 */


@Entity
@Table(name = "cms_program_back")
public class Programback{

    private static final long serialVersionUID = 1L;
    /**
     * 启用
     */
    public static final int NORMAL = 0;
    /*
     * 禁用
     */
    public static final int DISABLED = 1;

    /**
     * 站点
     */
    private Site site;

    /**
     * 卫视
     */
//    private Sinatv sinatv;


    private Integer id;
    private String name;
    private User user;
    private Date time;
    private String vadiotime;
    private Long playnum;
    private String smallImage;

    private List<ProgramDatecheack> programDatecheacks;

    public String url;   //最新回看日期节目单url


//    @ManyToOne(fetch = FetchType.LAZY)
//    @JoinColumn(name = "f_sinatv_id", nullable = false)
//    public Sinatv getSinatv() {
//        return sinatv;
//    }
//
//    public void setSinatv(Sinatv sinatv) {
//        this.sinatv = sinatv;
//    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "f_site_id", nullable = false)
    public Site getSite() {
        return site;
    }

    public void setSite(Site site) {
        this.site = site;
    }

    @Transient
    public String getUrl(){
        return this.url;
    }


    @Id
    @Column(name = "p_id", unique = true, nullable = false)
    @TableGenerator(name = "tg_cms_hot_word", pkColumnValue = "cms_hot_word", initialValue = 1, allocationSize = 10)
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "tg_cms_hot_word")
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(name = "p_channel", nullable = false, length = 100)
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }



    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "p_user_id", nullable = false)
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "p_time", nullable = false, length = 19)
    public Date getTime() {
        return this.time;
    }

    public void setTime(Date time) {
        this.time = time;
    }
    @Column(name = "p_videotime", nullable = false, length = 100)
    public String getVadiotime() {
        return vadiotime;
    }

    public void setVadiotime(String vadiotime) {
        this.vadiotime = vadiotime;
    }

    @Column(name = "p_playnum", nullable = false, length = 100)
    public Long getPlaynum() {
        return playnum;
    }

    public void setPlaynum(Long playnum) {
        this.playnum = playnum;
    }

    @OneToMany(mappedBy = "programback", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @OrderBy("name desc")
    public List<ProgramDatecheack> getProgramDatecheacks() {
        return programDatecheacks;
    }

    public void setProgramDatecheacks(List<ProgramDatecheack> programDatecheacks) {
        this.programDatecheacks = programDatecheacks;
    }

    @Column(name = "p_small_image", nullable = true)
    public String getSmallImage() {
        return smallImage;
    }

    public void setSmallImage(String smallImage) {
        this.smallImage = smallImage;
    }
}
